//以列表形式展示一些同学信息
const users = [
    {
        name: '冰洋',
        age: 21,
        gender: '男'
    },
    {
        name: '晨旭',
        age: 23,
        gender: '男'
    },
    {
        name: '庞晶',
        age: 18,
        gender: '女'
    },
    {
        name: '俊鑫',
        age: 18,
        gender: '女'
    },
];

const express = require('express');

const app = express();

app.get('/students', (req, res) => {
    //以列表展示学员数据 <ul><li></li></ul>
    //遍历users
    let str = '';
    //遍历拼接
    users.forEach(item => {
        str += `<li>${item.name} - ${item.age} - ${item.gender}</li>`
    });

    res.send(`<!DOCTYPE html>
                <html lang="en">
                <head>
                    <meta charset="UTF-8">
                    <meta http-equiv="X-UA-Compatible" content="IE=edge">
                    <meta name="viewport" content="width=device-width, initial-scale=1.0">
                    <title>学员列表</title>
                </head>
                <body>
                    <h2>学员列表</h2>
                    <ul>
                        ${str}
                    </ul>
                </body>
                </html>`);
});

app.listen(80, () => {
    console.log('启动成功....');
})
